<!DOCTYPE html>
<html>
    <head>
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel='stylesheet' href='style.css' type='text/css'>
    </head>

    <body class="page" onbeforeunload="stop()" onunload="stop()">
        <div class="header toolbar">
            <div class="logo" alt="VTK Web demo application"></div>
            <div class="loading"></div>
        </div>
        <div class="viewport-container">
        </div>

        <script src="../../lib/core/vtkweb-loader-min.js" load="core-min"></script>
        <script type="text/javascript">
            var config = {
                sessionManagerURL: vtkWeb.properties.sessionManagerURL,
                application: "cone"
            },
            stop = vtkWeb.NoOp,
            start = function(connection) {
                // Create viewport
                var viewport = vtkWeb.createViewport({session:connection.session});
                viewport.bind(".viewport-container");

                // Handle window resize
                $(window).resize(function() {
                    if(viewport) {
                        viewport.render();
                    }
                }).trigger('resize');

                // Update stop method to use the connection
                stop = function() {
                    connection.session.call('application.exit');
                }
            };

            // Try to launch the Viz process
            vtkWeb.smartConnect(config, start, function(code,reason){
                alert(reason);
            });
        </script>
    </body>
</html>
